package ztc.servlet;

import ztc.common.UserBean;
import ztc.service.DBTools;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * Created by ztc on 16-4-20.下午8:34
 */
public class DelSigin extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        HttpSession session=request.getSession();
        Integer siginID= Integer.valueOf(request.getParameter("id"));
        UserBean userBean= (UserBean) session.getAttribute("userBean");
        if(new DBTools().delSiginById(siginID,userBean.getId())){
            response.sendRedirect("/qr/showinf.jsp?msg="+ URLEncoder.encode("删除成功！", "utf-8"));
        }else{
            response.sendRedirect("/qr/showinf.jsp？msg="+URLEncoder.encode("删除失败，请重试！","utf-8"));
        }
    }
}
